#!/usr/bin/env python3
import sys
from pathlib import Path
from email import policy
from email.parser import BytesParser

def main(path):
    raw = Path(path).read_bytes()
    msg = BytesParser(policy=policy.default).parsebytes(raw)
    i = 0
    for part in msg.walk():
        print('PART', i)
        for k, v in part.items():
            print(' ', k + ':', v)
        i += 1

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print('usage: inspect_mht.py file.mht')
        sys.exit(1)
    main(sys.argv[1])
